// Tags: 01Trie
#include <algorithm>
#include <cstdio>

const int N = 3e5 + 5, bit = 31;
int n, m, tot, k, tr[N * bit][2], siz[N * bit];

inline void insert(int x) {
  int cur = 0;
  bool ch = 0;
  for (int i = bit - 1; ~i; --i) {
    ch = (x >> i) & 1;
    if (!tr[cur][ch]) tr[cur][ch] = ++tot;
    cur = tr[cur][ch];
  }
  siz[cur] = 1;
}

void dfs(int x) {
  if (!tr[x][0] && !tr[x][1]) return;
  if (tr[x][0]) dfs(tr[x][0]);
  if (tr[x][1]) dfs(tr[x][1]);
  siz[x] = siz[tr[x][0]] + siz[tr[x][1]];
}

inline int query() {
  int res = 0, cur = 0;
  bool ch;
  for (int i = bit - 1; ~i; --i) {
    ch = (k >> i) & 1;
    if (siz[tr[cur][ch]] == 1 << i) cur = tr[cur][!ch], res |= 1 << i;
    else
      cur = tr[cur][ch];
    if (!cur) break;
  }
  return res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("CF842D Vitya and Strange Lesson.in", "r", stdin);
  freopen("CF842D Vitya and Strange Lesson.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  int x;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    insert(x);
  }
  dfs(0);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &x);
    k ^= x;
    printf("%d\n", query());
  }
  return 0;
}